<template>
  <div class="hello">
    <h1>{{ msg }}</h1>

    <el-form :inline="true" :model="formInline" class="demo-form-inline">
      <el-row>
        <el-col :span="8">
          <div class="grid-content bg-purple">.</div>
        </el-col>
        <el-col :span="8">
          <el-form-item label="药品名称">
            <el-input data-mode="en" v-model="keyboard" placeholder="请输入药品名称"></el-input>
            <vue-dusion-keyboard float></vue-dusion-keyboard>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="onSubmit">查询</el-button>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <div class="grid-content bg-purple">.</div>
        </el-col>
      </el-row>
    </el-form>

    <el-row>
      <el-col :span="4">
        <div class="grid-content bg-purple">.</div>
      </el-col>
      <el-col :span="16">
        <ProductList ref="productList"/><!--搜索结果-->
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple">.</div>
      </el-col>
    </el-row>

  </div>
</template>

<script>
import ProductList from "@/components/ProductList";

export default {
  name: 'HelloWorld',
  data(){
    return {
      keyboard:''
    }
  },
  components: {ProductList},
  props: {
    msg: String
  },
  watch:{
    //开始监听返回该对象属性值计算属性
    keyboard: function(newVal, oldVal){
      console.log(newVal, oldVal);
      if (this.keyboard == ''){
        this.$refs.productList.clear();
      }
    }
  },
  methods: {
    onSubmit() {
      this.$refs.productList.search();
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}

ul {
  list-style-type: none;
  padding: 0;
}

li {
  display: inline-block;
  margin: 0 10px;
}

a {
  color: #42b983;
}
</style>
